package org.centny.bb;

import java.util.ArrayList;

/**
 * the Gaming interface for BaccaraBuilder.
 * 
 * @author Scorpion
 */
public interface Gaming {
	/**
	 * the enum for gaming result.
	 * 
	 * @author Scorpion
	 */
	public enum GamingOption {
		GOPT_BANK, GOPT_PLAY, GOPT_TIE
	}

	public static final class GRes {
		/**
		 * the gaming result.
		 */
		public GamingOption g;
		/**
		 * if have paired.
		 */
		public Boolean paired;
		/**
		 * the player cards.
		 */
		public ArrayList<Byte> p_cards;
		/**
		 * the banker cards.
		 */
		public ArrayList<Byte> b_cards;

		/**
		 * the gaming result object.
		 * 
		 * @param pcount
		 * @param bcount
		 * @param paired
		 */
		public GRes(ArrayList<Byte> p_cards, ArrayList<Byte> b_cards) {
			if (p_cards.size() < 2 || b_cards.size() < 2) {
				throw new RuntimeException("invalid cards count");
			}
			this.b_cards = b_cards;
			this.p_cards = p_cards;
			int pcount =BaccaratBuilder.residue(this.p_cards);
			int bcount = BaccaratBuilder.residue(this.b_cards);
			if (pcount == bcount) {
				this.g = GamingOption.GOPT_TIE;
			} else if (pcount > bcount) {
				this.g = GamingOption.GOPT_PLAY;
			} else {
				this.g = GamingOption.GOPT_BANK;
			}
			this.paired = BaccaratBuilder.isPair(this.p_cards, this.b_cards);
		}

	}
	/**
	 * execute gaming.
	 * 
	 * @param res
	 *            the gaming result.
	 */
	public void gaming(GRes res);
}
